from typing import Optional
from datetime import datetime
from decimal import Decimal
from pydantic import BaseModel, Field

class AirticketOrderFlightBase(BaseModel):
    airticket_order_id: int
    FlightNo: str = Field(..., description="航班号")
    CabinCode: str = Field(..., description="舱位代码")
    DepAirportCode: str = Field(..., description="出发机场代码")
    ArrAirportCode: str = Field(..., description="到达机场代码")
    DepCityName: str = Field(..., description="出发城市名称")
    ArrCityName: str = Field(..., description="到达城市名称")
    DepDTS: datetime = Field(..., description="出发时间")
    ArrDTS: datetime = Field(..., description="到达时间")
    PriceMark: Optional[str] = Field(None, description="价格标记")
    BasePrice: Decimal = Field(..., description="基础价格,Y舱全价")
    TicketPrice: Decimal = Field(..., description="票面价格")
    DiscountRate: Decimal = Field(..., description="折扣率")
    OrgProfitRate: Decimal = Field(..., description="原始利润率")
    ProfitRate: Decimal = Field(..., description="利润率")
    ExtraProfitRate: Decimal = Field(..., description="额外利润率，后返")
    AirportTax: Decimal = Field(..., description="机场税")
    FuelTax: Decimal = Field(..., description="燃油税")

class AirticketOrderFlightCreate(AirticketOrderFlightBase):
    pass

class AirticketOrderFlightUpdate(BaseModel):
    FlightNo: Optional[str] = None
    CabinCode: Optional[str] = None
    DepAirportCode: Optional[str] = None
    ArrAirportCode: Optional[str] = None
    DepCityName: Optional[str] = None
    ArrCityName: Optional[str] = None
    DepDTS: Optional[datetime] = None
    ArrDTS: Optional[datetime] = None
    PriceMark: Optional[str] = None
    BasePrice: Optional[Decimal] = None
    TicketPrice: Optional[Decimal] = None
    DiscountRate: Optional[Decimal] = None
    OrgProfitRate: Optional[Decimal] = None
    ProfitRate: Optional[Decimal] = None
    ExtraProfitRate: Optional[Decimal] = None
    AirportTax: Optional[Decimal] = None
    FuelTax: Optional[Decimal] = None

class AirticketOrderFlight(AirticketOrderFlightBase):
    ID: int

    class Config:
        from_attributes = True 